//
// Created by Sugars Mac on 2021/9/1.
//

#ifndef DVROUTING_COMMON_H
#define DVROUTING_COMMON_H

struct rtpkt {
    int sourceid;       /* id of sending router sending this pkt */
    int destid;         /* id of router to which pkt being sent
                         (must be an immediate neighbor) */
    int mincost[4];    /* min cost to node 0 ... 3 */
};

extern int TRACE;
extern int YES;
extern int NO;
extern float clocktime;
void tolayer2(struct rtpkt packet);
void creatertpkt(struct rtpkt *initrtpkt, int srcid, int destid, int mincosts[]);

struct distance_table {
    int costs[4][4];
};

void printTable(struct distance_table *dtptr, int me);
int min(int a, int b);
void send2Neighbors(struct distance_table *dtptr, int me);

#endif //DVROUTING_COMMON_H
